package com.brillilab.service.module.message.template.enums;

import com.brillilab.common.constant.ResultEnum;
import com.brillilab.common.exceptions.BrillilabException;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author zlb
 * @Title: MessageTypeEnum
 * @ProjectName brill_lab
 * @Description: TODO
 * @date 2019/5/24 17:41
 */
@Getter
@AllArgsConstructor
public enum MessageTypeEnum {

    //用户中心
    /** 非实验室PI直接添加成员成功 */
    NotLabPIAddMember(101,"NotLabPIAddMember"),
    /** 用户被移出实验室后*/
    RemoveLab(102,"RemoveLab"),
    /** 用户被召回实验室后*/
    ReCallLab(103,"ReCallLab"),
    /**用户注册成功(授权码/授权卡)后*/
    RegisterSuccess(104,"RegisterSuccess"),
    /**权限被修改成功后*/
    AuthByModifySuccess(105,"AuthByModifySuccess"),
    /**用户申请加入实验室待审核*/
    ApplyJoinLabWaitAudit(106,"ApplyJoinLabWaitAudit"),
    /**无成员管理权限的人邀请成员成功后*/
    NoMemberManageInviteSuccess(107,"NoMemberManageInviteSuccess"),
    /**实验室试用期过期前*/
    BeforeLabExpire(108,"BeforeLabExpire"),
    /**实验室试用期到期时*/
    WhenLabExpire(109,"WhenLabExpire"),
    /**用户账号试用期过期前*/
    BeforeUserExpire(110,"BeforeUserExpire"),
    /**用户账号试用期到期时*/
    WhenUserExpire(111,"WhenUserExpire"),

    //空间管理
    /**私有平面被修改成功为-公用*/
    PrivatePlaneModify(201,"PrivatePlaneModify"),
    /**私有平面被修改成功为-私有*/
    PrivatePlaneModifyToPrivate(202,"PrivatePlaneModifyToPrivate"),
    /**私有试剂盒被修改成功为-公用*/
    PrivateReagentBoxModify(203,"PrivateReagentBoxModify"),
    /**私有试剂盒被修改成功为-私有*/
    PrivateReagentBoxModifyToPrivate(204,"PrivateReagentBoxModifyToPrivate"),
    /**平面被修改为个人私有成功后*/
    PlaneModifyToPrivate(205,"PlaneModifyToPrivate"),
    /**试剂盒被修改为个人私有成功后*/
    ReagentBoxToPrivate(206,"ReagentBoxToPrivate"),


    //试剂模块
    /**管理员操作了私人试剂(取用/归还/删除)*/
    PIOperatePrivateReagent(301,"PIOperatePrivateReagent"),
    /**试剂分享后*/
    ReagentShare(302,"ReagentShare"),
    /**单个试剂被管理员移交给其他人-被移交用户*/
    SingleReagentToOther(303,"SingleReagentToOther"),
    /**单个试剂被管理员移交-移交目标用户*/
    SingleReagentToTargetUser(304,"SingleReagentToTargetUser"),
    /**试剂可用量触发预警值时*/
    ReagentAvailableWarn(305,"ReagentAvailableWarn"),

    //方法库模块
    /**成员分享方法后*/
    MemberShareMethod(401,"MemberShareMethod"),
    /**成员方法被管理员分享给其他成员*/
    MemberMethodToShareOther(402,"MemberMethodToShareOther"),
    /**管理员收到成员推荐方法*/
    ReceiveMemberRecommendMethod(403,"ReceiveMemberRecommendMethod"),
    /**收到管理员推荐的单条方法(无同三级类型)*/
    SingleRecommendMethod(404,"SingleRecommendMethod"),
    /**收到管理员推荐的多条方法(无同三级类型)*/
    MultiRecommendMethod(405,"MultiRecommendMethod"),
    /**成员的推荐方法审核通过*/
    RecommendMethodAuditPass(406,"RecommendMethodAuditPass"),
    /**成员的推荐方法审核未通过*/
    RecommendMethodAuditUnPass(407,"RecommendMethodAuditUnPass"),
    /**成员的推荐方法被修改后审核通过*/
    RecommendMethodModifyAuditPass(408,"RecommendMethodModifyAuditPass"),
    /**方法被管理员推荐给其他成员*/
    MethodToShareOther(409,"MethodToShareOther"),

    //课题模块
    /**非组长或PI的用户新增课题成员时*/
    NotLeaderOrPIAddTopicMember(501,"NotLeaderOrPIAddTopicMember"),
    /**实验目标被指派给其他成员时*/
    TargetToOtherMember(502,"TargetToOtherMember"),
    /**实验目标被非对应的执行成员作废后*/
    TargetToIsNotMemberDiscard(503,"TargetToIsNotMemberDiscard"),
    /**实验目标被非对应的执行成员恢复后*/
    TargetToIsNotMemberRecover(504,"TargetToIsNotMemberRecover"),
    /**主执行人结束课题时*/
    MainExecutorEndTopic(505,"MainExecutorEndTopic"),

    //实验模块
    /**实验倒计时结束时*/
    ExperimentCountdownEnd(601,"ExperimentCountdownEnd"),
    /**检测实验完成且符合预期的时候*/
    CheckExperimentAccordExpect(602,"CheckExperimentAccordExpect"),
    /**导师已审阅*/
    AdvisorChecked(603,"AdvisorChecked"),
    /**文件过期提醒*/
    FileExpireRemind(604,"FileExpireRemind"),

    //公告
    /**实验室内有公告发布时*/
    PublicAnnouncement(701,"PublicAnnouncement"),

    //仪器预约
    /**仪器预约取消预约*/
    InstrumentAppointmentCancel(801,"InstrumentAppointmentCancel"),
    /**仪器预约新增预约*/
    InstrumentAppointmentMake(802,"InstrumentAppointmentMake"),
    /**仪器预约修改预约*/
    InstrumentAppointmentChange(803,"InstrumentAppointmentChange"),
    /**仪器预约开始提醒*/
    InstrumentAppointmentAlert(804,"InstrumentAppointmentAlert"),

    //推送消息(此类型为透传模式，非通知类型)
    PushMessage(900,"PushMessage"),

    /**PI、组长、主执行人帮组员添加了计划*/
    ManagerAddPlan(1001,"ManagerAddPlan"),
    /**PI、组长、主执行人帮组员修改了计划时间*/
    ManagerModifyPlanTime(1002,"ManagerModifyPlanTime"),
    /**PI、组长、主执行人帮组员移除了计划*/
    ManagerRemovePlan(1003,"ManagerRemovePlan"),
    /**同一个实验流的成员将实验流加入了计划*/
    MemberDoExperimentTargetJoinPlan(1004,"MemberDoExperimentTargetJoinPlan")
    ;
    private Integer value;
    private String name;

    public static Integer getValue(String name){
        MessageTypeEnum[] enums=MessageTypeEnum.values();
        for (MessageTypeEnum messageTypeEnum :enums){
            if(messageTypeEnum.name.equals(name)){
                return messageTypeEnum.value;
            }
        }
        throw new BrillilabException(ResultEnum.DATA_NOT_EXIST);
    }

    public static MessageTypeEnum getEnum(Integer key) {
        for(MessageTypeEnum e : MessageTypeEnum.values()) { if(e.getName().equals(key))return e;}
        return null;
    }

    public static String getName(Integer key) {
        MessageTypeEnum e = getEnum(key);
        return e!=null?e.getName():null;
    }
}
